﻿
using System;

using IronLua.Hosting;
using IronLua.Parser;

using Dlr = Microsoft.Scripting;
using Microsoft.Scripting;
using Microsoft.Scripting.Ast;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Shell;

namespace IronLua.Runtime {

	public class LuaContext : LanguageContext {

		public override string DisplayName {
			get { return "IronLua"; }
		}

		public LuaContext (ScriptDomainManager manager) : base (manager)
		{
		}

		public override CodeBlock ParseSourceCode (CompilerContext context)
		{
			var parser = new LuaParser ();

			throw new NotImplementedException ();
		}

		public override TService GetService<TService> (params object [] args)
		{
			var service = typeof (TService);

			if (service == typeof (OptionsParser)) {
				return ToService<TService> (new LuaOptionsParser ());
			} else if (service == typeof (CommandLine)) {
				return ToService<TService> (new LuaCommandLine ());
			}

			return base.GetService<TService> (args);
		}

		static TService ToService<TService> (object o)
		{
			return (TService) o;
		}
	}
}